<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <center>
        <form action="{:url('index/add')}">
            <table>
                <tr>
                    <td>姓名</td>
                    <td><input type="text" name="name" id="name"><span></span></td>
                </tr>
                <tr>
                    <td>性别</td>
                    <td>
                        <input type="radio" value="男">男
                        <input type="radio" value="女">女
                    </td>
                </tr>
                <tr>
                    <td>身份证号</td>
                    <td><input type="text" name="sfz" id="sfz"><span></span></td>
                </tr>
                <tr>
                    <td>班级号</td>
                    <td>
                        <select name="cid">
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td colspan="2"><input type="submit" value="添加"></td>
                </tr>
            </table>
        </form>
    </center>
</body>
</html>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script>
    $(document).on("blur","#name",function () {
        var name = $(this).val();
        if (name == ''){
            $(this).next().text("姓名不能为空");
        }else
            $(this).next().text("");
        }
    })

    $(document).on("blur","#sfz",function () {
        var sfz = $(this).val();
        if (sfz == ''){
            $(this).next().text("身份证号不能为空");
        }else{
            $(this).next().text("");
        }
    })
</script>